package org.healer.simple_juc;

public class TestPriority implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"----->"+Thread.currentThread().getPriority());

    }


    public static void main(String[] args) {
        //主线程默认,优先级为5
        System.out.println(Thread.currentThread().getName()+"----->"+Thread.currentThread().getPriority());
        TestPriority tp=new TestPriority();

        Thread t1 = new Thread(tp);
        Thread t2 = new Thread(tp);
        Thread t3 = new Thread(tp);
        Thread t4 = new Thread(tp);
        Thread t5 = new Thread(tp);
        Thread t6 = new Thread(tp);

        //设置优先级
        t1.start();
        t2.setPriority(1);
        t2.start();
        t3.setPriority(4);
        t3.start();
        t4.setPriority(Thread.MAX_PRIORITY);
        t4.start();
        t5.setPriority(-1);
        t5.start();
        t6.setPriority(11);
        t6.start();
    }
}
